import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:myturngame/widget/combat/dialog_skill_command.dart';
import 'package:myturngame/widget/home/dialog_skill.dart';

import '../../bean/message.dart';
import '../../common/game_global.dart';
import '../bag/bag_dialog.dart';
import '../debug_dialog.dart';
import '../map_dialog.dart';
import '../role_info_dialog.dart';

///主页的操作按钮
///@author Administrator
///@date 2023年2月9日23:58:48

class LayoutOperation extends StatelessWidget {
  Function(String) mapClick;
  Function(Message) messageAdd;

  LayoutOperation(this.mapClick, this.messageAdd, {Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.bottomRight,
      child: Column(
        mainAxisSize: MainAxisSize.min,
        mainAxisAlignment: MainAxisAlignment.end,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.end,
            children: [
              OutlinedButton(
                  onPressed: () {
                    //展示地图弹窗
                    showDialog(
                        context: context,
                        builder: (BuildContext context) {
                          return Dialog(
                            child: DebugDialog(messageAdd),
                          );
                        });
                  },
                  child: const Text("指令")),
              const SizedBox(width: 5),
              OutlinedButton(
                  onPressed: () {
                    //展示地图弹窗
                    showDialog(
                        context: context,
                        builder: (BuildContext context) {
                          return DialogSkill();
                        });
                  },
                  child: const Text("法术")),
            ],
          ),
          Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              OutlinedButton(
                  onPressed: () {
                    showDialog(
                        context: context,
                        builder: (BuildContext context) {
                          return Dialog(
                            child: RoleInfoWidget(GameGlobal.player),
                          );
                        });
                  },
                  child: const Text("角色")),
              const SizedBox(width: 5),
              OutlinedButton(
                  onPressed: () {
                    showDialog(
                        context: context,
                        builder:
                            bagDialogBuilder(GameGlobal.player, (item) => {}));
                  },
                  child: const Text("背包")),
              const SizedBox(width: 5),
              OutlinedButton(
                  onPressed: () {
                    //展示地图弹窗
                    showDialog(
                        context: context,
                        builder: mapDialogBuilder((mapClick)));
                  },
                  child: const Text("地图")),
            ],
          )
        ],
      ),
    );
  }
}
